
var Settings = (function(){

	function handleForm() {

		$('.form-control').on('change', function(e){
			
			var input = $(e.currentTarget),
				form = input.parents('form').first(),
				data = {};

			var values = $.each(form.serializeArray(), function(i, o){
					data[o.name] = o.value;
				});

			$.ajax({
				url: siteURL('settings/save'),
				type: 'post',
				data: data,
				beforeSend: function() {
					// $('#pagetitle').html('Saving...');
				}
			})
			.always(function(){
				// $('#pagetitle').html($('#pagetitle').data('title'));
			});

		});

	}

	return {
		init: function() {
			handleForm();
		}
	};

}(jQuery));

$(document).ready(Settings.init);